import { Component, OnInit } from '@angular/core';
import { uniqueId } from 'lodash';

interface DemoUser {
  id: string;
  name: string;
  age: number;
  expand: boolean;
  random: number;
  disabled: boolean;
}

@Component({
  selector: 'app-demo22',
  templateUrl: './demo22.component.html',
  styles: [
    `
      .multi-line {
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        white-space: normal;
      }
      ul {
        margin-top: 0.16rem;
      }
    `,
  ],
})
export class Demo22Component implements OnInit {
  data: DemoUser[];
  constructor() {}

  ngOnInit() {
    this.initData();
  }

  initData() {
    this.data = Array.from({ length: 10 }).map((item, key) => {
      return this.initUser(key, key % 2 !== 0);
    });
  }

  initUser(key: number, disabled: boolean) {
    return {
      id: uniqueId('uid'),
      name: `user${key}`,
      age: 10 + key,
      expand: false,
      random: parseInt(Math.random() * 100 + '', 10),
      disabled,
      description: [
        { label: 'The story begi ns as Don Vito Corleone, ' },
        { label: 'the head of a New York Mafia family, ' },
        { label: `overseeshis daughter's wedding.` },
      ],
      isMatch: true,
    };
  }

  getFileDetail(e) {
    console.log(e);
  }
}
